Skip to content

fix: propagate json.Unmarshal error in mysql rowDataConverter#6721

Open
vedant21-oss wants to merge 1 commit intopipe-cd:masterfrom
vedant21-oss:fix-mysql-iterator-json-error
Open

fix: propagate json.Unmarshal error in mysql rowDataConverter#6721
vedant21-oss wants to merge 1 commit intopipe-cd:masterfrom
vedant21-oss:fix-mysql-iterator-json-error

Conversation

@vedant21-oss
Copy link
Copy Markdown

Resolves #6699

The rowDataConverter in the MySQL datastore now returns an error that bubbles up through Iterator.Next() to handle silent json.Unmarshal failures.

@vedant21-oss vedant21-oss requested a review from a team as a code owner April 27, 2026 13:45
@vedant21-oss vedant21-oss force-pushed the fix-mysql-iterator-json-error branch from 9fdb89b to 28a2188 Compare April 27, 2026 13:52
Copy link
Copy Markdown
Contributor

@eeshaanSA eeshaanSA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vedant21-oss, thanks for this. Do you have any logs that can support this?

Did anyone try reproducing?

@rahulshendre @Ayushmore1214

@vedant21-oss vedant21-oss force-pushed the fix-mysql-iterator-json-error branch from 28a2188 to b8199ef Compare April 27, 2026 14:28
@vedant21-oss
Copy link
Copy Markdown
Author

Hey @eeshaanSA, thanks for the review!

I just updated the PR to include a unit test that explicitly reproduces this behavior in pkg/datastore/mysql/iterator_test.go.

Without the fix, the JSON unmarshaling silently failed, and an empty/partial object was returned. With this fix, running the tests explicitly captures the error. Here is the log output from the new testcase simulating invalid JSON data from the database:

=== RUN TestData/invalid_json_data
iterator_test.go:152: Expected error caught: unexpected end of JSON input
--- PASS: TestData/invalid_json_data (0.00s)

The unmarshal error is now properly propagated up to the caller instead of being swallowed. I've force-pushed the test coverage alongside the fix.

Copy link
Copy Markdown
Contributor

@rahulshendre rahulshendre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced locally. All tests pass, invalid_json_data catches the error correctly.
One note:
Cursor() error path (lines 62-65 of iterator.go) isn't covered by any test case, it returns nil.
@vedant21-oss i think we should add a case there too

Signed-off-by: vedant21-oss <vedantmalodeofficial@gmail.com>
@vedant21-oss vedant21-oss force-pushed the fix-mysql-iterator-json-error branch from b8199ef to 38143bd Compare May 1, 2026 13:17
@rahulshendre
Copy link
Copy Markdown
Contributor

rahulshendre commented May 5, 2026

hey @vedant21-oss, any updates on this one 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing error handling on json.Unmarshal inside MySQL Row Iteration

3 participants